package server;
import hostconfig.HostConfig;

import java.io.IOException;

import java.net.ServerSocket;
import java.net.Socket;

import communication.Communication;


public class Server 
{
	public static void main(String[] args) throws IOException, ClassNotFoundException 
	{
		ServerSocket serverSocket = new ServerSocket(HostConfig.getPort());
		//Socket clients [] = new Socket [10];
		System.out.println("Started listening...");
		
		while(true)
		{
			Socket socket = serverSocket.accept();
			System.out.println("Connected: " + socket.getInetAddress());
			Communication communication = new Communication(socket);
			communication.sendMessage("Baglandik");
			System.out.println("Message sent waiting response");
			System.out.println(communication.getMessage());
			communication.close();
		}
	}
}
